package org.springframework.retry.samples.service.impl;

import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.retry.samples.service.RetryService;
import org.springframework.stereotype.Service;

/**
 * @author Webster
 * <p>
 * Description:
 * </p>
 * @date 2021/4/13
 * @see org.springframework.retry.samples.service.impl
 */
@Service
public class RetryServiceImpl implements RetryService {

    @Retryable(recover = "myRecover",value = Exception.class, maxAttempts = 2, backoff = @Backoff(delay = 3000, multiplier = 1, maxDelay = 10000))
    @Override
    public void retryDemo(){
        System.out.println("执行业务！！！");
        int a = 2 / 0;
        System.out.println("业务完成！！！");

    }

    @Recover
    public void myRecover(Exception e) {
        System.out.println("我的回调方法！！！");
    }
    @Recover
    public void recover(Exception e) {
        System.out.println("默认回调方法！！！");
    }
}
